package com.springboot.tiki.controller;

import com.springboot.tiki.service.BucketService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName BucketController
 * @Description: 桶管理控制类
 * @author: kuaiqing
 * @CreateDate: 2025/10/22 14:21
 * @Version: 1.0
 */
@RestController
@RequestMapping("/bucket")
public class BucketController {

     public BucketController(BucketService bucketService) {
        this.bucketService = bucketService;
    }
    private final BucketService bucketService;

      @GetMapping("/create")
      public String createBucket(String bucketName) {
      bucketService.createBucket(bucketName);
        return "创建成功";
     }
    @GetMapping("/delete")
    public String deleteBucket(String bucketName) {
      bucketService.deleteBucket(bucketName);
        return "删除成功";
     }
    @GetMapping("/lists")
    public void lists() {
         bucketService.listBucket();
    }
    @PostMapping("/putObject")
    public String putObject(MultipartFile file, String bucketName) {
        return bucketService.putObject(file,bucketName);
    }
    @GetMapping("/getPresignedObjectUrl")
    public String getPresignedObjectUrl(String bucketName, String objectName) {
        return bucketService.getPresignedObjectUrl(bucketName,objectName);
    }
    @GetMapping("/getObject")
    public void getObject(String bucketName, String objectName, HttpServletResponse response) {
         bucketService.getObject(bucketName,objectName,response);
    }
    @GetMapping("/listObjects")
    public void listObjects(String bucketName) {
        bucketService.listObjects(bucketName);
    }
    @GetMapping("/removeObject")
    public void removeObject(String bucketName, String objectName) {
        bucketService.removeObject(bucketName,objectName);
    }



}

